import { BaseController } from '@/api/BaseController';
import { RequestOption } from '@/common/http/types';
import { ANY_OBJECT } from '@/types/generic';
import { TableData } from '@/common/types/table';
import { useUrlBuilder } from '@/common/hooks/useUrl';
import TestFlowSubmit from '@/types/table/testFlowSubmit';
import { TestFlowSubmitDetailData } from '@/api/generated/testFlowSubmitDetailController';
import { API_CONTEXT } from '../config';

const { buildGetUrl } = useUrlBuilder();

export interface TestFlowSubmitData extends TestFlowSubmit {
  testFlowSubmitDetailList?: TestFlowSubmitDetailData[];
  __cascade_add_temp_id__?: string | number | undefined;
}

export default class TestFlowSubmitController extends BaseController {
  static list(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return super.post<TableData<TestFlowSubmitData>>(API_CONTEXT + '/app/testFlowSubmit/list', params, httpOptions);
  }
  static view(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return super.get<TestFlowSubmitData>(API_CONTEXT + '/app/testFlowSubmit/view', params, httpOptions);
  }
  static export(params: ANY_OBJECT, fileName: string) {
    return super.download(API_CONTEXT + '/app/testFlowSubmit/export', params, fileName);
  }
  static import(params: ANY_OBJECT) {
    return super.upload(API_CONTEXT + '/app/testFlowSubmit/import', params);
  }
  static printUrl(params: ANY_OBJECT) {
    return buildGetUrl(API_CONTEXT + '/app/testFlowSubmit/print', params);
  }
  static startOnlyFlowSubmit(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return super.post(API_CONTEXT + '/app/testFlowSubmit/startOnly/flowSubmit', params, httpOptions);
  }
  static startWithBusinessKeyFlowSubmit(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return super.post(API_CONTEXT + '/app/testFlowSubmit/startWithBusinessKey/flowSubmit', params, httpOptions);
  }
  static startAndTakeUserTaskFlowSubmit(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return super.post(API_CONTEXT + '/app/testFlowSubmit/startAndTakeUserTask/flowSubmit', params, httpOptions);
  }
  static startAndSaveDraftFlowSubmit(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return super.post(API_CONTEXT + '/app/testFlowSubmit/startAndSaveDraft/flowSubmit', params, httpOptions);
  }
  static submitUserTaskFlowSubmit(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return super.post(API_CONTEXT + '/app/testFlowSubmit/submitUserTask/flowSubmit', params, httpOptions);
  }
  static viewTaskBusinessDataFlowSubmit(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return super.get(API_CONTEXT + '/app/testFlowSubmit/viewTaskBusinessData/flowSubmit', params, httpOptions);
  }
  static viewHistoricTaskBusinessDataFlowSubmit(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return super.get(API_CONTEXT + '/app/testFlowSubmit/viewHistoricTaskBusinessData/flowSubmit', params, httpOptions);
  }
  static listWorkOrderFlowSubmit(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return super.post(API_CONTEXT + '/app/testFlowSubmit/listWorkOrder/flowSubmit', params, httpOptions);
  }
}
